//
//  AGNetRequestHistoryCell.swift
//  AG_Test
//
//  Created by AG on 2020/12/3.
//

import UIKit

class AGNetRequestHistoryCell: UITableViewCell {
    
    var titleLabel: UILabel!
    var subTitleLabel: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        // maekUI
        self.backgroundColor = UIColor.clear
        selectionStyle = .none
        createCotetView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func createCotetView() {
        let bgView = UIView()
        bgView.backgroundColor = UIColor.clear
        self.contentView.addSubview(bgView)
        
        titleLabel = UILabel()
        titleLabel.textAlignment = .left
        titleLabel.text = "https://api.github.com/"
        titleLabel.font = UIFont.systemFont(ofSize: 14)
        titleLabel.textColor = UIColor.black
        bgView.addSubview(titleLabel)
        
        subTitleLabel = UILabel()
        subTitleLabel.textAlignment = .left
        subTitleLabel.text = ""
        subTitleLabel.font = UIFont.systemFont(ofSize: 12)
        subTitleLabel.textColor = UIColor.gray
        bgView.addSubview(subTitleLabel)
        
        let line = UIView()
        line.backgroundColor = UIColor.gray
        bgView.addSubview(line)
        
        bgView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.right.equalToSuperview().inset(16)
            make.top.equalToSuperview().offset(12)
            make.height.equalTo(16)
        }
        
        subTitleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.right.equalToSuperview().inset(16)
            make.top.equalTo(titleLabel.snp_bottomMargin).offset(16)
            make.height.equalTo(14)
        }
        
        line.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(0.5)
        }
    }
    
    func refresh(_ text: String) {
        self.subTitleLabel.text = text
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
